package com.yuerenjf.yuerenjinfu.adapter;

import android.app.Activity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.nostra13.universalimageloader.core.ImageLoader;
import com.yuerenjf.yuerenjinfu.R;
import com.yuerenjf.yuerenjinfu.bean.FindTabBean;
import com.yuerenjf.yuerenjinfu.utils.MyDisplayImageOptions;

import java.util.List;

/**
 * Created by Administrator on 2017/6/13 0013.
 */

public class AdapterFindTop extends BaseAdapter {
    Activity mActivity;
    private List<FindTabBean.FindUrlNameBean> beanList;

    public AdapterFindTop(Activity mActivity, List<FindTabBean.FindUrlNameBean> beanList) {
        this.mActivity = mActivity;
        this.beanList = beanList;
    }

    @Override
    public int getCount() {
        return beanList.size();
    }

    @Override
    public Object getItem(int i) {
        return null;
    }

    @Override
    public long getItemId(int i) {
        return 0;
    }

    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {
        View convertView = null;
        ViewHolder viewHolder;
        if (convertView == null) {
            viewHolder = new ViewHolder();
            convertView = LayoutInflater.from(mActivity).inflate(R.layout.item_find_top, null);
            viewHolder.imageView = (ImageView) convertView.findViewById(R.id.item_find_top_image);
            viewHolder.textView = (TextView) convertView.findViewById(R.id.item_find_top_text);
            convertView.setTag(viewHolder);
        } else {
            viewHolder = (ViewHolder) convertView.getTag();
        }

        FindTabBean.FindUrlNameBean bean = beanList.get(i);
        ImageLoader.getInstance().displayImage(bean.getImage(), viewHolder.imageView,MyDisplayImageOptions.getInstance(0));
        viewHolder.textView.setText(bean.getName());


        return convertView;
    }

    class ViewHolder {
        ImageView imageView;
        TextView textView;
    }
}
